// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   AnytableBO.java

package com.vandagroup.common.util.anytable;

import com.vandagroup.common.bo.ESSBO;
import com.vandagroup.common.bo.UserContext;
import com.vandagroup.common.util.Result;
import com.vandagroup.common.util.SQLUtility;
import java.io.PrintStream;
import java.sql.SQLException;

// Referenced classes of package com.vandagroup.common.util.anytable:
//            AnytablePO, AnytableFormBean

public class AnytableBO extends ESSBO
{

    AnytablePO po;
    UserContext user;

    public AnytableBO()
    {
        po = new AnytablePO();
        user = null;
    }

    public Result query(int pageNO, AnytableFormBean bean)
        throws SQLException, Exception
    {
        po.setTableName(bean.getTablename());
        po.setColumnNames(bean.getDispfield());
        String whereClause = "";
        if(!user.getOperID().equals("00000000"))
            whereClause = " ( orgid='" + user.getOrgID() + "' or uporgid='" + user.getOrgID() + "')";
        String StaticClause = bean.getStaticClause();
        if(StaticClause != null && !StaticClause.equals("null") && !StaticClause.trim().equals(""))
            whereClause = SQLUtility.addWhereClause(whereClause, StaticClause);
        whereClause = SQLUtility.addWhereClause(whereClause, "STATUS", "1");
        whereClause = SQLUtility.addLikeClause(whereClause, bean.getKey(), bean.getKeyValue());
        System.out.println("AnytableBO:query:whereClause::" + whereClause);
        po.setWhereClause(whereClause);
        if(bean.getDbName() != null)
            po.setDbName(bean.getDbName());
        System.out.println(po.getSql());
        po.setResultPage(20, pageNO);
        po.setOrderBy(bean.getKey());
        Result result = po.queryResult();
        return result;
    }

    public void setUser(UserContext user)
    {
        this.user = user;
    }
}
